package utl.mofen.handler;


import java.util.Calendar;

import com.google.gson.JsonObject;

import utl.mofen.jsonStreamHandler.JSonStreamHandler;

public class ServerINfoHandler extends JSonStreamHandler {
	private final static int GET_TIME = 1; // 获取服务器时间
	
	public void doAction() throws Exception {
		JsonObject json = this.jsonStream.getJSonObject();				
		int action = json.get("action").getAsInt();
		
		switch (action) {
		case GET_TIME:
			Calendar c = Calendar.getInstance();
			JsonObject data = new JsonObject();
			
			data.addProperty("YY", c.get(Calendar.YEAR));
			data.addProperty("MM", c.get(Calendar.MONTH) + 1);
			data.addProperty("DD", c.get(Calendar.DATE));
			data.addProperty("hh", c.get(Calendar.HOUR_OF_DAY));
			data.addProperty("mi", c.get(Calendar.MINUTE));
			data.addProperty("ss", c.get(Calendar.SECOND));
			data.addProperty("ms", c.get(Calendar.MILLISECOND));
			json.add("time", data);
			break;
		}
	}
}
